package com.financial.business.balance.service.impl;

import com.financial.business.balance.constants.FinancialPaymentBalanceEnumConstants;
import com.financial.business.balance.service.FinancialBalancePaymentService;
import com.financial.business.balance.service.yspay.FinancialBalanceYsPaymentService;
import com.financial.business.balance.utils.JsonUtils;
import com.financial.business.balance.utils.apiresult.ApiResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @Author WANGNING
 * @Email wyn20140226@aliyun.com
 * @Description //余额代付业务处理
 * @Date 2019/12/4 10:27
 */
@Service
public class FinancialBalancePaymentServiceImpl implements FinancialBalancePaymentService {
    public static final Logger logger = LoggerFactory.getLogger(FinancialBalancePaymentServiceImpl.class);

    @Autowired
    private FinancialBalanceYsPaymentService financialBalanceYsPaymentService;
    @Override
    public ApiResult payment(String requestParam) {
        logger.info("FinancialBalancePaymentServiceImpl.payment()-----余额代付/转账获取到的json信息为："+requestParam);
        /*解析参数信息判断支付渠道*/
        Map<String,Object> map = JsonUtils.jsonToMap(requestParam);
        String paymentChannelNo=(String)map.get("payment_channel_no");
        logger.info("FinancialBalancePaymentServiceImpl.payment()-----余额代付/转账渠道为："+paymentChannelNo);
        ApiResult apiResult=ApiResult.failure(FinancialPaymentBalanceEnumConstants.ENUM_YSPAYMENT_INIT);
        /*判断代付、转账渠道*/
        if(paymentChannelNo.equalsIgnoreCase(FinancialPaymentBalanceEnumConstants.ENUM_PAYMENTCHANNEL_YSBALANCE)){
            /*银盛平台余额代付、转账*/
            apiResult=financialBalanceYsPaymentService.payment(requestParam);
        }
        return apiResult;
    }
}
